CMAKE_MINIMUM_REQUIRED(VERSION 2.4)

SET(CMAKE_CXX_FLAGS_DEBUG TRUE)
IF(COMMAND CMAKE_POLICY)
    CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND CMAKE_POLICY)

LIST(APPEND CMAKE_MODULE_PATH "/usr/share/cmake/Modules")

PROJECT(Amaranthus)

FIND_PACKAGE(VTK 5.10 REQUIRED)
IF(VTK_FOUND)
    INCLUDE(${VTK_USE_FILE})
ELSE(VTK_FOUND)
    MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(VTK_FOUND)

FIND_PACKAGE(ITK)
IF(ITK_FOUND)
    INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
    MESSAGE(FATAL_ERROR "Please set ITK_DIR.")
ENDIF(ITK_FOUND)

FIND_PACKAGE(OpenGL REQUIRED)
IF(NOT OPENGL_FOUND)
    MESSAGE(FATAL_ERROR "OPENGL not found!")
ENDIF(NOT OPENGL_FOUND)

FIND_PACKAGE(Qt4 REQUIRED)
IF(NOT QT4_FOUND)
    MESSAGE(FATAL_ERROR "Qt4 not found!")
ENDIF(NOT QT4_FOUND)
SET(QT_USE_QTOPENGL TRUE)
SET(QT_USE_QTGUI TRUE)
INCLUDE(${QT_USE_FILE})

#FIND_PACKAGE(Qwt5 REQUIRED)

#FIND_PACKAGE(Geant4 REQUIRED)
#INCLUDE(${Geant4_USE_FILE})

INCLUDE_DIRECTORIES(
    ${CMAKE_SOURCE_DIR}/Common
    ${CMAKE_SOURCE_DIR}/Logic
    ${CMAKE_SOURCE_DIR}/Logic/Framework
    ${CMAKE_SOURCE_DIR}/Logic/ImageData
    ${CMAKE_SOURCE_DIR}/Logic/ProjectManager
    ${CMAKE_SOURCE_DIR}/Logic/Segmentation
    ${CMAKE_SOURCE_DIR}/Logic/Visualization
    ${CMAKE_SOURCE_DIR}/Logic/DoseCalculation
    ${CMAKE_SOURCE_DIR}/Logic/DoseCalculation/Geant4
    ${CMAKE_SOURCE_DIR}/Logic/DoseCalculation/Determenistic
    ${CMAKE_SOURCE_DIR}/GUI
    ${CMAKE_SOURCE_DIR}/GUI/ProjectWizard
    ${CMAKE_SOURCE_DIR}/GUI/ImageIOWizard
#   ${CMAKE_SOURCE_DIR}/GUI/MaterialWizard
    ${CMAKE_SOURCE_DIR}/GUI/SystemImages
    ${CMAKE_SOURCE_DIR}/Extras
    ${OPENGL_INCLUDE_PATH}
    ${Qwt5_INCLUDE_DIR}
    ${CMAKE_CURRENT_BINARY_DIR}
)

SET(AmaranthusGUI_SRCS
    AmaranthusMain.cpp
    GUI/MainWindow.cpp
    GUI/ImageIOWizard/ImageIOWizard.cpp
    Logic/Visualization/SlicerWidget.cpp
    Logic/Visualization/VolumeWidget.cpp
    Logic/Visualization/VisWidgetBase.cpp
    Extras/QVTKWidget2.cxx
#   GUI/ProjectWizard/ProjectWizard.cpp
#   GUI/MaterialWizard/MaterialWizard.cpp
)

QT4_WRAP_CPP(QT_MOC_SRCS
    GUI/MainWindow.h
    GUI/ImageIOWizard/ImageIOWizard.h
    Logic/Framework/CoreImageData.h
    Logic/ImageData/ImageWrapperBase.h
    Logic/ImageData/SegImageWrapper.h
    Logic/ImageData/VisImageWrapper.h
    Logic/Visualization/SlicerWidget.h
    Logic/Visualization/VolumeWidget.h
    Logic/Visualization/VisWidgetBase.h
    Extras/QVTKWidget2.h
#   GUI/MaterialWizard/MaterialWizard.h
#   GUI/ProjectWizard/ProjectWizard.cpp
#   Logic/ProjectManager/ProjectManager.cpp
)

QT4_WRAP_UI(QT_UIC_SRCS
    GUI/MainWindow.ui
    GUI/ImageIOWizard/FilePage.ui
    GUI/ImageIOWizard/HeaderPage.ui
    GUI/ImageIOWizard/ACTHeaderPage.ui
    GUI/ImageIOWizard/ACT_ROIPage.ui
#   GUI/MaterialWizard/MaterialWizard.ui
#   GUI/ProjectWizard/...
)

QT4_ADD_RESOURCES(QT_QRC_SRCS
    GUI/SystemImages.qrc
)

SET(AmaranthusLOGIC_CPP
    Logic/Framework/CoreImageData.cpp
    Logic/Framework/DoseCalculationData.cpp
    Logic/ImageData/GreyImageWrapper.cpp
    Logic/ImageData/SegImageWrapper.cpp
    Logic/ImageData/VisImageWrapper.cpp
    Logic/ImageData/ImageCoordinateGeometry.cpp
    Logic/ImageData/GuidedNativeImageIO.cpp
    Logic/ImageData/ConvertNativeImageToGrey.cpp
    Logic/Segmentation/SimpleAutomaticSegmentation.cpp
#    Logic/DoseCalculation/Geant4/Geant4Calculator.ccp
#    Logic/DoseCalculation/Geant4/DetectorConstruction.ccp
#    Logic/DoseCalculation/Geant4/RegularDetectorConstruction.ccp
#    Logic/DoseCalculation/Geant4/PhysicsList.ccp
#    Logic/DoseCalculation/Geant4/PrimaryGeneratorAction.ccp
#    Logic/DoseCalculation/Geant4/RunAction.ccp
#    Logic/DoseCalculation/Geant4/Run.ccp
)

SET(AmaranthusLOGIC_HEADERS
    Common/AmaranthusCommon.h
    Logic/Framework/DoseCalculationData.h
    Logic/ImageData/ImageWrapperBase.h
    Logic/ImageData/GreyImageWrapper.h
    Logic/ImageData/ImageCoordinateGeometry.h
    Logic/ImageData/GuidedNativeImageIO.h
    Logic/ImageData/ConvertNativeImageToGrey.h
    Logic/Segmentation/SimpleAutomaticSegmentation.h
    Extras/itkImageToVTKImageFilter.h
    Extras/itkImageToVTKImageFilter.txx
 #   Logic/DoseCalculation/Geant4/Geant4Calculator.h
 #   Logic/DoseCalculation/Geant4/DetectorConstruction.h
 #   Logic/DoseCalculation/Geant4/RegularDetectorConstruction.h
 #   Logic/DoseCalculation/Geant4/PhysicsList.h
 #   Logic/DoseCalculation/Geant4/PrimaryGeneratorAction.h
 #   Logic/DoseCalculation/Geant4/RunAction.h
 #   Logic/DoseCalculation/Geant4/Run.h
 #   Logic/DoseCalculation/Geant4/EventAction.h
)

ADD_EXECUTABLE(Amaranthus
    ${AmaranthusGUI_SRCS}
    ${AmaranthusLOGIC_HEADERS}
    ${AmaranthusLOGIC_CPP}
    ${QT_MOC_SRCS}
    ${QT_UIC_SRCS}
    ${QT_QRC_SRCS}
)

TARGET_LINK_LIBRARIES(Amaranthus
    QVTK
    ${QT_LIBRARIES}
    ${Qwt5_Qt4_LIBRARY}
    ${OPENGL_LIBRARIES}
    ${ITK_LIBRARIES}
#    ${Geant4_LIBRARIES}
    ITKCommon
    vtkCommon
)


